home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Magazine / SoundLab / Studio16add / sources / S16FileInfo.asm < prev    next >
Encoding:
Assembly Source File  |  1997-12-10  |  9.2 KB  |  353 lines

  1. *>b:S16FileInfo
  2.  
  3.     *«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  4.     *   Copyright © 1997 by Kenneth "Kenny" Nilsen.  E-Mail: kenny@bgnett.no              *
  5.     *   Source viewed in 800x600 with mallx.font/thin711.font (11) in CED                  *
  6.     *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  7.     *
  8.     *   Name
  9.     *    S16FileInfo
  10.     *
  11.     *   Function
  12.     *    Show some information on Studio 16 files
  13.     *
  14.     *   Inputs
  15.     *    <file> [options]
  16.     *
  17.     *    -l = list SampleClips list
  18.     *    -r = list Region list
  19.     *
  20.     *   Notes
  21.     *    Use PhxAss to assemble this source.
  22.     *    This source is the public domain as long as original copyright is used.
  23.     *
  24.     *    The *>... in top is used for PhxAss Arexx scipt (Aminet) from CygnusED.
  25.     *
  26.     *   Bugs
  27.     *    
  28.     *   Created    : 14.11.97
  29.     *   Changes    : 14.11.97, 17.11.97, 26.11.97
  30.     *««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  31.  
  32.  
  33.         Incdir    inc:
  34.  
  35.         include    lvo/exec_lib.i
  36.         include    lvo/dos_lib.i
  37.  
  38.         include    libraries/studio16file.i
  39.         include    dos/dos.i
  40.         include    exec/types.i
  41.  
  42.         include    digital.macs
  43.         include    startup.asm
  44.  
  45.         Incdir    ""
  46.  
  47.         dc.b    "$VER: S16FileInfo 2.2 (26.11.97)",10
  48.         dc.b    "Copyright © 1997 Digital Surface. All rights reserved. ",0
  49.         even
  50. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  51. Dump    macro    ;Open -> ErrorOpen Dump ErrOpen
  52. Error\1    move.l    #Err\1,d1
  53.     bra    Print
  54.     endm
  55.  
  56. Buffer    =    S16S_SIZEOF
  57. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  58. Init        DefLib    dos,37        ;open dos.library version 37 (NewStartup.asm)
  59.         DefEnd            ;no more libs to open
  60.  
  61. Start    NextArg                ;get Arg if any
  62.     beq    About            ;none then show About
  63.     move.l    d0,a0
  64.     cmp.b    #'?',(a0)        ;asked for about
  65.     beq    About
  66.  
  67.     lea    IFile(pc),a1
  68. .copyI    move.b    (a0)+,(a1)+        ;copy firstarg=filename to buffer
  69.     bne.b    .copyI
  70.  
  71. .argLoop                ;get options if any
  72.     NextArg
  73.     beq    .argsOk            ;end of args
  74.     move.l    d0,a0
  75.     and.b    #($ff-$20),1(a0)    ;upper case option
  76.  
  77.     cmp.w    #'-L',(a0)        ;is it -l or -L
  78.     beq    .setList
  79.     cmp.w    #'-R',(a0)        ;is it -r or -R
  80.     bne    About
  81.  
  82. .setRegion
  83.     st    Regions            ;set Show Regions true
  84.     bra    .argLoop
  85. .setList
  86.     st    List            ;set Show SampleClips true
  87.     bra    .argLoop
  88. *------------------------------------------------------------------------------------------------------------*
  89. .argsOk
  90.  
  91. ; open file and IDentify
  92.  
  93.     LibBase    dos
  94.     move.l    #IFile,d1        ;filename
  95.     move.l    #MODE_OLDFILE,d2
  96.     Call    Open
  97.     move.l    d0,IHan
  98.     beq    ErrorOpen        ;error opening ?
  99.  
  100. ; alloc memory for header
  101.  
  102.     LibBase    exec
  103.     move.l    #Buffer,d0
  104.     move.l    #$10001,d1
  105.     Call    AllocMem        ;alloc memory for header
  106.     move.l    d0,Mem
  107.     beq    ErrorMem
  108.  
  109. ; read header into buffer
  110.  
  111.     LibBase    dos
  112.     move.l    IHan(pc),d1
  113.     move.l    Mem(pc),d2
  114.     move.l    #Buffer,d3
  115.     Call    Read            ;read header into memory
  116.     cmp.l    d3,d0
  117.     bne    ErrorRead
  118.  
  119. ; ID of file
  120.  
  121.     move.l    Mem(pc),a0
  122.     cmp.l    #'KWK3',(a0)        ;IDentify file
  123.     bne    ErrorType
  124.  
  125. *------------------------------------------------------------------------------------------------------------*
  126. ; recalc volume
  127.  
  128.     move.w    S16S_VOLUME(a0),d0
  129.     asr.w    #5,d0            ;/32
  130.     sub.w    #100,d0            ;-100 (so we get dB)
  131.     move.w    d0,S16S_VOLUME(a0)
  132.  
  133. ; recalc pan
  134.  
  135.     move.l    S16S_PAN(a0),d0
  136.     asr.l    #5,d0            ;/32
  137.     move.l    d0,S16S_PAN(a0)
  138.  
  139. ; recalc SMPTE
  140.  
  141.     move.l    S16S_SMPTE(a0),d0    ;SMPTE LONG word
  142.     moveq    #0,d1
  143.     move.b    d0,d1
  144.     move.w    d1,S16S_SMPTE+6(a0)    ;store FF - _SMPTEFLOAT is overwritten here
  145.     asr.l    #8,d0
  146.     move.b    d0,d1
  147.     move.w    d1,S16S_SMPTE+4(a0)    ;store SS - _SMPTEFLOAT is overwritten here
  148.     asr.l    #8,d0
  149.     move.b    d0,d1
  150.     move.w    d1,S16S_SMPTE+2(a0)    ;store MM
  151.     asr.l    #8,d0
  152.     move.b    d0,d1
  153.     move.w    d1,S16S_SMPTE(a0)    ;store HH
  154.  
  155. *------------------------------------------------------------------------------------------------------------*
  156. ; count SampleClips
  157.  
  158.     lea    S16S_EDITLIST(a0),a1    ;Show main clip as well
  159.     moveq    #0,d0            ;SampleClip counter
  160.     moveq    #MAXSAMPLECLIPS-1,d1    ;list tracker counter
  161. .countS    move.l    (a1)+,d2        ;_START
  162.     move.l    (a1)+,d3        ;_END
  163.     beq    .smpEnd
  164.     addq.l    #1,d0            ;we had one, add one to counter
  165.     dbra    d1,.countS
  166.  
  167. .smpEnd    move.l    d0,S16S_FLAGS(a0)    ;use the _FLAG field since we won't use it anyway
  168.     cmp.l    #1,d0
  169.     bne    .numSC            ;no SampleClips ?
  170.     clr.b    List            ;then set user-want-list to false (no list)
  171. .numSC
  172. *------------------------------------------------------------------------------------------------------------*
  173. ; count Regions
  174.  
  175.     lea    S16S_REGIONLIST(a0),a1    ;ptr. to regions
  176.     moveq    #0,d0            ;Regions counter
  177.     moveq    #MAXREGIONS-1,d1    ;list tracker counter
  178. .countR    tst.b    (a1)            ;Null terminated ? then we're done
  179.     beq    .regEnd
  180.     addq.l    #1,d0            ;add one if a Region
  181.     lea    S16R_SIZEOF(a1),a1    ;next region struct
  182.     dbra    d1,.countR
  183.  
  184. .regEnd    move.l    d0,S16S_RES(a0)        ;store in this field since we won't use it anyway
  185.     bne    .regList        ;no regions ?
  186.     clr.b    Regions            ;set user-want-region-list to false
  187. .regList
  188.  
  189. *------------------------------------------------------------------------------------------------------------*
  190. ; OK, we're ready to dump info to user
  191.  
  192.     LibBase    exec
  193.     lea    String(pc),a0
  194.     move.l    Mem(pc),a1
  195.     move.l    #Ifile,(a1)        ;set filename where ID is
  196.     lea    Proc(pc),a2
  197.     lea    Buff(pc),a3
  198.     Call    RawDoFmt        ;format what we have using header as table
  199.  
  200.     LibBase    dos
  201.     move.l    #Buff,d1
  202.     Call    PutStr            ;show formatted buffer
  203.  
  204. *------------------------------------------------------------------------------------------------------------*
  205. ; do user want a SampleClip list ?
  206.  
  207.     tst.b    List            ;show SampleClips ?
  208.     beq    .noList
  209.  
  210.     move.l    #SampleList,d1
  211.     Call    PutStr
  212.  
  213.     move.l    Mem(pc),a5
  214.     lea    S16S_EDITLIST(a5),a5    ;use _EDITLIST
  215. .Sloop    move.l    (a5)+,d0        ;_START
  216.     move.l    (a5)+,d1        ;_END
  217.     beq    .noList
  218.     addq.l    #1,d1            ;add one to _END
  219.     move.l    d0,Table        ;store in table
  220.     move.l    d1,Table+4
  221.     sub.l    d0,d1            ;range SIZE
  222.     move.l    d1,Table+8
  223.  
  224.     LibBase    exec
  225.     lea    SampleString(pc),a0
  226.     lea    Table(pc),a1
  227.     lea    Proc(pc),a2
  228.     lea    Buff(pc),a3
  229.     Call    RawDoFmt
  230.  
  231.     LibBase    dos
  232.     move.l    #Buff,d1
  233.     Call    PutStr            ;show SampleClip entry
  234.  
  235.     bra    .Sloop
  236.  
  237. *------------------------------------------------------------------------------------------------------------*
  238. ; do user want a Region list ?
  239.  
  240. .noList    tst.b    Regions            ;show Regions ?
  241.     beq    .done
  242.  
  243.     move.l    #RegionList,d1
  244.     Call    PutStr
  245.  
  246.     move.l    Mem(pc),a5
  247.     lea    S16S_REGIONLIST(a5),a5    ;ptr. to Regions
  248. .Rloop    tst.b    (a5)
  249.     beq    .done            ;null term. ? then done
  250.  
  251.     move.l    S16R_START(a5),d0    ;_START
  252.     move.l    S16R_END(a5),d1        ;_END
  253.     addq.l    #1,d1            ;add one to _END
  254.     move.l    d0,Table
  255.     move.l    d1,Table+4
  256.     sub.l    d0,d1            ;SIZE of range
  257.     move.l    d1,Table+8
  258.     move.l    a5,Table+12        ;name on region (first in struct)
  259.  
  260.     LibBase    exec
  261.     lea    RegionString(pc),a0
  262.     lea    Table(pc),a1
  263.     lea    Proc(pc),a2
  264.     lea    Buff(pc),a3
  265.     Call    RawDoFmt
  266.  
  267.     LibBase    dos
  268.     move.l    #Buff,d1
  269.     Call    PutStr            ;show Region entry
  270.  
  271.     lea    S16R_SIZEOF(a5),a5    ;next Region
  272.     bra    .Rloop
  273.  
  274. *------------------------------------------------------------------------------------------------------------*
  275. .done    move.l    #EndString,d1
  276.     Call    PutStr
  277. *------------------------------------------------------------------------------------------------------------*
  278. Close    LibBase    exec            ;clean up memory if any
  279.     move.l    Mem(pc),d0
  280.     beq    .noMem
  281.     move.l    d0,a1
  282.     move.l    #Buffer,d0
  283.     Call    FreeMem
  284.  
  285. .noMem    LibBase    dos            ;clean up handler if any
  286.     move.l    Ihan(pc),d1
  287.     beq    .noIn
  288.     Call    Close
  289.  
  290. .noIn    move.l    Warn(pc),d0        ;return code (0=ok, 5=some error)
  291.     rts
  292. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  293. Proc    move.b    d0,(a3)+
  294.     rts
  295.  
  296. ; show errors
  297.  
  298.     Dump    Open
  299.     Dump    Mem
  300.     Dump    Read
  301.     Dump    Type
  302.  
  303. About    move.l    #AboutTxt,d1
  304.  
  305. Print    move.w    #5,Warn+2
  306.     LibBase    dos
  307.     Call    PutStr
  308.     bra    Close
  309. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  310. Warn        dc.l    0
  311. Mem        dc.l    0
  312. IHan        dc.l    0
  313.  
  314. Table        dc.l    0,0,0
  315.  
  316. IFile        dcb.b    300,0
  317. Buff        dcb.b    600,0
  318.  
  319. List        dc.b    0
  320. Regions        dc.b    0
  321. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  322. ErrOpen        dc.b    "Couldn't open file!",10,0
  323. ErrMem        dc.b    "Out of memory - need 3690 bytes!",10,0
  324. ErrRead        dc.b    "Error reading file - file is mangled!",10,0
  325. ErrType        dc.b    "Not a Studio 16 file (KWK3)!",10,0
  326.  
  327. String        dc.b    10
  328.         dc.b    27,"[1mFileinfo",27,"[0m on sample '",27,"[3m%s",27,"[0m'",10,10
  329.         dc.b    "             Samplerate: %ld",10
  330.         dc.b    "                 Filter: %ld",10
  331.         dc.b    "                 Volume: %d dB",10
  332.         dc.b    "                  SMPTE: %02.d:%02.d:%02.d:%02.d",10
  333.         dc.b    "                    PAN: %ld",10,10
  334.         dc.b    "  Number of SampleClips: %ld",10
  335.         dc.b    "      Number of Regions: %ld",10,10
  336.         dc.b    "       Real Sample size: %ld samples",10
  337.         dc.b    "       Edit Sample size: %ld samples",10,0
  338.  
  339. SampleString    dc.b    27,"[1mSTART",27,"[0m: %9.ld - ",27,"[1mEND",27,"[0m: %9.ld - ",27,"[1mSIZE",27,"[0m: %9.ld",10,0
  340. RegionString    dc.b    27,"[1mSTART",27,"[0m: %9.ld - ",27,"[1mEND",27,"[0m: %9.ld - ",27,"[1mSIZE",27,"[0m: %9.ld ('%s')",10,0
  341.  
  342. EndString    dc.b    10,0
  343.  
  344. SampleList    dc.b    10,27,"[1mSAMPLECLIPS:",27,"[0m",10,10,0
  345. RegionList    dc.b    10,27,"[1mREGIONS:",27,"[0m",10,10,0
  346.  
  347. AboutTxt    dc.b    10,27,"[1mS16FileInfo",27,"[0m 2.2 by Kenneth 'Kenny' Nilsen (kenny@bgnett.no)",10
  348.         dc.b    "-----------------------------------------------------------",10,10
  349.         dc.b    "    USAGE: S16FileInfo <file> [-l] [-r]",10,10
  350.         dc.b    "    -l = List SampleClips list",10
  351.         dc.b    "    -r = List Region list",10,10,0
  352. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  353.